import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
//import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { sjlyOptionsListApi } from '@/api/wyf/pms/select';
import { xzqhTreeSelectListApi } from '@/api/wyf/xzqh/select';
import { gxqyOptionsListApi } from '@/api/wyf/user/gxqySelect';
// import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '房源编号',
    align: 'left',
    width: 200,
    dataIndex: 'wyfbh',
    //resizable: true,
  },
  {
    title: '房源名称',
    align: 'left',
    dataIndex: 'fh',
    //resizable: true,
  },
  {
    title: '管辖单位',
    align: 'left',
    dataIndex: 'gxdwmc',
    // resizable: true,
  },
  {
    title: '所属区域',
    align: 'left',
    dataIndex: 'xzqh_dictText',
    // resizable: true,
  },
  {
    title: '详细地址',
    align: 'left',
    dataIndex: 'fwdz',
    width: 200,
    // resizable: true,
  },
  {
    title: '经营类型',
    align: 'left',
    dataIndex: 'jyrlx',
    customRender: ({ text }) => {
      return render.renderDict(text, 'jyrlx');
    },
  },
  {
    title: '经营者',
    align: 'left',
    dataIndex: 'jyrxm',
    customRender: ({ record }) => {
      const jyrlx = record['jyrlx'];
      if (jyrlx === '1' || jyrlx === '3') {
        return record['jyrxm']; // 当 jyrlx 为 1 时，显示 jyrxm
      } else if (jyrlx === '2') {
        return record['jyrdwmc']; // 当 jyrlx 为 2 时，显示 jyrdwmc
      }
      return ''; // 默认返回空
    },
  },
  {
    title: '经营状态',
    align: 'left',
    dataIndex: 'fwjyzt',
    customRender: ({ text }) => {
      return render.renderDict(text, 'fwjyzt');
    },
  },
  {
    title: '数据来源',
    align: 'left',
    dataIndex: 'sjly_dictText',
    width: 170,
    // resizable: true,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  // {
  //   field: 'xzqh',
  //   label: '所属区域',
  //   component: 'ApiTreeSelect',
  //   componentProps: {
  //     api: xzqhTreeSelectListApi,
  //     params: {},
  //     resultField: 'result',
  //     multiple: true,
  //   },
  // },
  {
    label: '房源名称',
    field: 'fh',
    component: 'Input', //渲染的组件
    componentProps: {
      //  dictCode: 'status',
    },
  },
  {
    field: 'gxqy',
    label: '管辖单位',
    //component: 'ApiTreeSelect',
    component: 'JCascader',
    componentProps: {
      api: gxqyOptionsListApi,
      params: {},
      //resultField: 'title',
      // fieldNames: {
      //   label: 'id_dictText',
      //   value: 'id',
      // },
      // multiple: true,
      changeOnSelect: true,
    },
  },
  {
    field: 'xzqh',
    label: '所属区域',
    //component: 'ApiTreeSelect',
    component: 'JCascader',
    componentProps: {
      api: xzqhTreeSelectListApi,
      params: {},
      //resultField: 'title',
      // fieldNames: {
      //   label: 'title',
      //   value: 'value',
      // },
      // multiple: true,
      changeOnSelect: true,
    },
  },
  {
    label: '房源编号',
    field: 'wyfbh',
    component: 'Input', //渲染的组件
    componentProps: {
      //  dictCode: 'status',
    },
  },
  {
    label: '详细地址',
    field: 'fwdz',
    component: 'Input', //渲染的组件
  },
  {
    label: '数据来源',
    field: 'sjly',
    component: 'ApiSelect', //渲染的组件
    //defaultValue: '', //设置默认值
    componentProps: {
      api: sjlyOptionsListApi,
      resultField: 'result',
      labelField: 'mc',
      valueField: 'id',
    },
  },
  {
    label: '经营类型',
    field: 'jyrlx',
    component: 'JDictSelectTag', //渲染的组件
    //defaultValue: '', //设置默认值
    componentProps: {
      dictCode: 'jyrlx',
    },
  },
  {
    label: '经营者',
    field: 'jyrxm',
    component: 'Input', //渲染的组件
  },
  {
    label: '经营状态',
    field: 'fwjyzt',
    component: 'JDictSelectTag', //渲染的组件
    //defaultValue: '', //设置默认值
    componentProps: {
      dictCode: 'fwjyzt',
    },
  },
];
